import defaultSettings from '@/settings'
// 对于系统配置项的结构与运用
const { showSettings, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  showSettings: showSettings,
  fixedHeader: fixedHeader, // 导航是否固定
  sidebarLogo: sidebarLogo // 是否显示侧边栏主菜单标题
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    // 判断是否包含本属性
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  /**
   * @description: 控制系统菜单栏的功能
   * @author: zengxiaolong
   * @Date: 2023-01-26 17:20:09
   * @param {*} commit 提交方法
   * @param {*} data 参数
   */
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  // 命名空间
  namespaced: true,
  state,
  mutations,
  actions
}

